package com.edu.learning.concurrent.custom;

import com.edu.learning.concurrent.custom.queue.IBlockingQueue;
import com.edu.learning.concurrent.custom.queue.TraditionalBlockingQueue;

/**
 * @Author ll
 * @Date 2017/10/16 17:36
 */
public class ProducerConsumerDemo {

    public static void main(String[] args) {
        new ProducerConsumerDemo().testRun(new TraditionalBlockingQueue<String>());
//        new ProducerConsumerDemo().testRun(new ConditionBlockingQueue<String>());
    }

    private void testRun(IBlockingQueue<String> queue) {
        Thread thread = new Thread(new Producer(queue, 2));
        thread.start();

        Thread consumer1 = new Thread(new Consumer(queue));
        consumer1.start();
        Thread consumer2 = new Thread(new Consumer(queue));
        consumer2.start();
    }
}
